package com.example.demo.controller;

import com.example.demo.model.User;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
public class UserController {
    @RequestMapping("/add")
    public User add(User user){
        return user;
    }

    //重命名
    @RequestMapping("/name")
    public String name(@RequestParam("n") String name){
        return name;
    }

    //接收前端的json对象
    @RequestMapping("/add_json")
    public User addByJson(@RequestBody User user){
        return null;
    }
}
